#pragma once

#include "iworld_loader.h"
#include "misc/strutil.h"

namespace renderit
{
	namespace messiah
	{
		class iworld_manager
		{
		public:
			bool load_worlds(const std::string& dir, std::function<void(int)> on_completed);
			bool load_worlds(const std::vector<std::string>& world_fpaths, std::function<void(int)> on_completed);

			uint32 replace_guid(const std::string& from_guid, const std::string& to_guid);

			void save();

			iworld_loader * get_loader(std::string name)
			{
				for (auto& l : iworld_loaders_)
				{
					if (l->fname_ == name)
					{
						return l;
					}
				}
				return nullptr;
			}

		private:
			void on_loaded(iworld_loader* loader);

		private:
			std::string dir_;
			std::function<void(int)> callback_;

			std::vector<iworld_loader*> iworld_loaders_;
			uint32 loading_count_;
		};
	}
}